package com.open.pokergames.base.activity;

import android.view.View;

import com.open.pokergames.R;
import com.sinothk.android.views.TitleBarView;

import org.greenrobot.eventbus.EventBus;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Deprecated
public abstract class EventBusTitleBaseActivity extends BaseActivity {


//    @Subscribe(threadMode = ThreadMode.MAIN)
//    public fun eventBusCallback(result: ResultInfo<JuBaoChaXunBean>) {
//        if (result.eventType != "getReplyByCode") {
//            return
//        }
//
//        hideLoadingDialog()
//
//        when (result.code) {
//            ResultInfo.SUCCESS -> {
//                if (result.data != null) {
//                    XUtils.intent().openActivity(this, JuBao12380ChaXunResultActivity::class.java)
//                        .putSerializableExtra("result", result.data)
//                            .start()
//                } else {
//                    XUtils.toast().show("查无结果")
//                }
//            }
//            ResultInfo.TOKEN_OVERDUE -> {
//            }
//            else -> {
//                XUtils.toast().show(result.msg)
//            }
//        }
//    }

    public String stringFilterChinese(String str){
        //只允许汉字
        String regEx = "[^\u4E00-\u9FA5]";
        Pattern p  = Pattern.compile(regEx);
        Matcher m  = p.matcher(str);
        return m.replaceAll("").trim();
    }

    protected TitleBarView titleBarView;

    public void setLeftViewGone() {
        titleBarView = this.findViewById(R.id.titleBarView);
        titleBarView.setLeftVisible(View.INVISIBLE);
    }

    public void setViewTitle(String centerTxt) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.icon_back);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
    }

    public void setViewTitle(String centerTxt, String subTitleTxt) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.icon_back);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterSubTxt(subTitleTxt);
    }

    public void setViewTitle(String centerTxt, int imgResId, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.icon_back);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);

        titleBarView.setRight1Icon(imgResId, clickListener);
    }

    public void setViewTitle(String centerTxt, String rightTxt, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.icon_back);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);

        titleBarView.setRight1Txt(rightTxt, clickListener);
    }

    public void setViewTitle(String centerTxt, String subTitleTxt, String rightTxt, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.icon_back);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterSubTxt(subTitleTxt);

        titleBarView.setRight1Txt(rightTxt, clickListener);
    }

    public void setViewTitle(String centerTxt, String subTitleTxt, int rightIcon, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.icon_back);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterSubTxt(subTitleTxt);

        titleBarView.setRight1Icon(rightIcon, clickListener);
    }
}
